<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Peiqi(uname, age) {
            this.uname = uname
            this.age = age
        }
        Peiqi.prototype.sing = function () {
            console.log('我会唱歌');
        }
        function Father(uname, age) {
            Peiqi.call(this, uname, age)
        }
        Father.prototype = new Peiqi()
        const peiqi = new Peiqi('小猪佩奇', 15)
        // console.log(peiqi);
        const father = new Father('猪爸爸', 28)
        // console.log(father);
        Father.prototype.constructor = Father
        Father.prototype.dance = function () {
            console.log('我会跳舞');
        }
        father.dance()
        father.sing()
        peiqi.sing()
        // peiqi.dance()














        // function Father(uname, age) {
        //     this.uname = uname
        //     this.age = age
        //     // console.log(this);
        //     // this.money = function () {
        //     //     console.log('我赚了一个小目标');
        //     // }
        // }
        // Father.prototype.money = function () {
        //     console.log('我赚了一个小目标');
        // }


        // function Son(uname, age) {
        //     Father.call(this, uname, age)
        // }

        // //把Father的原型对象给了Son(覆盖)
        // // Son.prototype = Father.prototype

        // //把Father的实例化对象给了Son(覆盖)
        // Son.prototype = new Father()

        // //将Son.prototype的constructor属性指回Son构造函数
        // Son.prototype.constructor = Son

        // //给Son.prototype添加新的方法
        // Son.prototype.exam = function () {
        //     console.log('我今天考了100分');
        // }

        // const son = new Son('ls', 18)
        // const father = new Father('zs', 40)
        // // console.log(uname);
        // console.log(son);
        // son.money()
        // son.exam()
        // father.exam()
        // father.exam()
        // father.exam()
    </script>
</body>

</html>